package com.lanou.horo.zhuizhui.utility.factory;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.SparseArray;

import com.lanou.horo.zhuizhui.fragment.PictureContentFragment;

/**
 * Created by dllo on 15/10/20.
 */
public class PictureFragmentFactory {
    private static SparseArray<Fragment> fragmentMap = new SparseArray<>();

    public static Fragment createFragment(int position) {
        Fragment f = fragmentMap.get(position);
        if (f == null) {
            String url = null;
            switch (position) {
                case 0:

                    url = "http://api.zhuizhuiyoyo.com/request.php?method=welfare%2Flist&timestamp=" +
                            "1446012735089&param=%7B%22count%22%3A20%2C%22o%22%3A%22n%22%2C%22page%22%3A1%2C%22" +
                            "user_id%22%3A0%7D&sig=1067da7f5258e3fe18717a98a3b7c090";
                    break;
                case 1:

                  url = "http://api.zhuizhuiyoyo.com/request.php?method=welfare%2Flist&timestamp=" +
                          "1446019968089&param=%7B%22count%22%3A20%2C%22o%22%3A%22h%22%2C%22page%22%3A1%2C%22" +
                          "user_id%22%3A0%7D&sig=40aab2b826d1189ae135fa5388583959";
                    break;


            }
            f = new PictureContentFragment(url);
            Bundle args = new Bundle();
            args.putInt("position", position);
            f.setArguments(args);
            fragmentMap.put(position, f);
        }
        return f;
    }
}
